//
//  ClubTableViewCell.m
//  SugarPile
//
//  Created by Charlie. on 16/1/22.
//  Copyright © 2016年 www.lanou39.蓝鸥科技. All rights reserved.
//

#import "ClubTableViewCell.h"
#import "LCPrefixHeader.pch"
@implementation ClubTableViewCell

// 内存管理
- (void)dealloc
{
    [_commentView release];
    [_commentLabel release];
    [_contentLabel release];
    [_pathView release];
    [_userNameLabel release];
    [_timeLaberl release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 评论图
        self.commentView = [[UIImageView alloc]init];
                _commentView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_commentLabel];
        [_commentLabel release];
        
        //评论数
        self.commentLabel = [[UILabel alloc]init];
        //  _pingCount.backgroundColor = [UIColor redColor];
        [self.commentView addSubview:_commentLabel];
        [_commentLabel release];
        
        //文字
        self.contentLabel = [[UILabel alloc]init];
        //  _title.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_contentLabel];
        _contentLabel.font = [UIFont systemFontOfSize:15];
        [_contentLabel release];
        
        //图片
        self.pathView = [[UIImageView alloc]init];
        //  _photo.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_pathView];
        [_pathView release];
        
        //用户姓名
        self.userNameLabel = [[UILabel alloc]init];
        // _userName.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_userNameLabel];
        [_userNameLabel release];
        
        //时间
        self.timeLaberl = [[UILabel alloc]init];
        //  _time.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_timeLaberl];
        [_timeLaberl release];
    }
    return self;
}
- (void)layoutSubviews
{
    
    [super layoutSubviews];
    // tupian
    _pathView.frame = CGRectMake(10 * W, 10 * H, 80 * W, 80 * W);
    // 图片
    _commentView.frame = CGRectMake(100 * W, 80 * H, 30 * W, 30 * W);
    _commentView.image = [UIImage imageNamed:@"book"];
    // 查看
    _commentLabel.frame = CGRectMake(130 * W, 80 * H, 100 * W, 30 * W);
    _commentLabel.numberOfLines = 0;
    // titel
    
    _contentLabel.frame = CGRectMake(100 * W, 10 * H, 250 * W, 30 * W);
    _contentLabel.numberOfLines = 0;
    
   
    _userNameLabel.frame = CGRectMake(100 * W, 30 * H, 250 * W, 60 * W);
    _userNameLabel.numberOfLines = 0;
    _userNameLabel.textColor = [UIColor grayColor];
    
    
    
    // _time.frame = CGRectMake(310, 160, 40, 30);
    
    
}

// 计算文本高度
+(CGFloat)heightWithText:(NSString *)text Size:(CGFloat)fontSize
{
    NSDictionary *dic = @{NSFontAttributeName: [UIFont systemFontOfSize:fontSize]};
    // 预设尺寸 文本最大不超过这个尺寸
    // 根据设置的宽度计算高度(宽度和label保持一致)
    CGSize size = CGSizeMake(WIDTH - 30, 1000);
    
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    // 返回得到的高度
    
    return rect.size.height;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
